# Contributor: Oleg Titov <oleg.titov@gmail.com>
# Maintainer: Oleg Titov <oleg.titov@gmail.com>
pkgname=py3-databases
pkgver=0.8.0
pkgrel=2
pkgdesc="Async database support for Python"
url="https://www.encode.io/databases/"
# there is no py3-httpx and py3-starlette for armhf and ppc64le
arch="all !armhf !ppc64le"
license="BSD-3-Clause"
makedepends="
	py3-build
	py3-gpep517
	py3-setuptools
	py3-wheel"
checkdepends="
	py3-aiopg
	py3-httpx
	py3-pytest
	py3-pytest-cov
	py3-sqlalchemy
	py3-starlette
	py3-requests
	"
subpackages="$pkgname-doc $pkgname-pyc"
source="databases-$pkgver.tar.gz::https://github.com/encode/databases/archive/refs/tags/$pkgver.tar.gz"
builddir="$srcdir/databases-$pkgver"

build() {
	gpep517 build-wheel \
		--wheel-dir dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages testenv
	testenv/bin/python3 -m installer dist/*.whl

	# some tests need databases and some tests known to fail
	export TEST_DATABASE_URLS="postgres://localhost"
	testenv/bin/python3 -m pytest \
		--ignore tests/test_connection_options.py \
		--ignore tests/test_databases.py \
		--ignore tests/test_integration.py
}

package() {
	python -m installer -d "$pkgdir" dist/*.whl

	install -Dm644 README.md -t "$pkgdir"/usr/share/doc/$pkgname
}

sha512sums="
c409d08908a2645e53bec5436c6050f0d3b488ef8d14952aa21e753deec02c75e7234ffe00917249604f43a4d4afd2f13040368ab3c3efa239647653e273fd1e  databases-0.8.0.tar.gz
"
